#!/usr/bin/python3
# -*- coding: utf-8 -*-
#======================================#
# @Author   : duanqizhong
# @time     : 2022-3-12 11:49
# @file     : api_user
# @Software : PyCharm
#======================================#
from flask import Blueprint, request, make_response, jsonify

from apps.api.common_func import all_business, all_app
from apps.config import ERROR_RESPONSE

business_bp = Blueprint("business", __name__, url_prefix="/api/v1/business")

@business_bp.route("/info", methods=("GET",))
def business():
    try:
        args = request.args
        business = args["business"]
        infos = all_business(business)
        return make_response(jsonify(infos))
    except Exception as e:
        ERROR_RESPONSE["msg"] = str(e)
    return make_response(jsonify(ERROR_RESPONSE))


@business_bp.route("/app/info", methods=("GET",))
def app():
    try:
        args = request.args
        app = args["app"]
        infos = all_app(app)
        return make_response(jsonify(infos))
    except Exception as e:
        ERROR_RESPONSE["msg"] = str(e)
    return make_response(jsonify(ERROR_RESPONSE))